#include "entity.h"

Entity::Entity(RenderData render_data)
	: Drawable(render_data)
{
	pos = Vec4(render_data.texture);
}

Entity::Entity(RenderData render_data, Sprite sprite)
	: Drawable(render_data, sprite)
{
	pos = Vec4(render_data.texture);
}

void Entity::update(State& state, bool pressed_keys[], int& camera_x, int& camera_y)
{
	if (pos.x - camera_x >= state.window_w + 10 ||
		pos.x - camera_x + pos.w < -10 ||
		pos.y - camera_y >= state.window_h + 10 ||
		pos.y - camera_y + pos.h < -10) {
		render_data.on_screen = false;
		return;
	}

	render_data.dst.x = pos.x - camera_x;
	render_data.dst.y = pos.y - camera_y;
	render_data.on_screen = true;
}

void Entity::render(SDL_Renderer *renderer)
{
	Drawable::render(renderer);
}

inline void Entity::scale(int w, int h)
{
	pos.scale(w, h);
	render_data.dst.scale(w, h);
}

inline void Entity::scale(float f)
{
	pos.scale(f);
	render_data.dst.scale(f);
}